package com.zhangtai.modules.controller.admin;

import java.util.Arrays;
import java.util.Map;

import com.zhangtai.modules.entity.orgin.TbOrgEhrEntity;
import com.zhangtai.modules.service.baseFromMssql.BaseMssqlServiceImpl;
import com.zhangtai.modules.service.orgin.TbOrgEhrService;
import com.zhangtai.utils.PageUtils;
import com.zhangtai.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 
 *
 * @author wanwgei
 * @email i@weiwang.com
 * @date 2021-05-19 20:16:28
 */
@RestController
@Api(tags="组织管理")
@RequestMapping("tborgehr")
public class TbOrgEhrController {
    @Autowired
    private BaseMssqlServiceImpl baseMssqlService;
    @Autowired
    private TbOrgEhrService tbOrgEhrService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbOrgEhrService.queryPage(params);
        return R.ok(page);
    }


    /**
     * 信息
     */
    @ApiOperation("按组织id查询该组织及以下组织")
    @GetMapping("/info/{orgid}")
    public R info(@PathVariable("orgid") String orgid){
		TbOrgEhrEntity tbOrgEhr = tbOrgEhrService.selectById(orgid);
        return R.ok(tbOrgEhr);
    }

    /**
     * 保存
     */
    @ApiOperation("新增组织")
    @PostMapping("/save")
    public R save(@RequestBody TbOrgEhrEntity tbOrgEhr){
		tbOrgEhrService.save(tbOrgEhr);
         return R.ok();
    }


    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation("修改")
    public R update(@RequestBody TbOrgEhrEntity tbOrgEhr){
        System.out.println(tbOrgEhr);
		tbOrgEhrService.updateById(tbOrgEhr);
        return R.ok();
    }



    /**
     *根据传入的组织ID 删除对应的组织
     * @return
     */
    @GetMapping("/delete/{orgid}")
    @ApiOperation("逻辑删除")
    public R deleteByOrgId(@PathVariable("orgid") int orgid){
         tbOrgEhrService.removeByOrgIds(orgid);
        return R.ok();
    }




}
